using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Xml;
using System.Windows.Forms;
using System.Collections;

namespace ConnectServer
{
    public class cConection
    {
        MService.Service WebService = new ConnectServer.MService.Service();
        //MailService.Service MailService = new ConnectServer.MailService.Service();

        public string con = DirectConnect.Conn;

        public void test()
        {
            //WebService.SelectData();
            //WebService.InsertData();
        }
        public string UpdateParameter(string SQL, string parameterName, byte[] image, string Connection)
        {
            WebService.Url = getUrl();
            return WebService.UpdateParameter(SQL, parameterName, image, Connection);
            //return "";
        }
        public string UpdateParameter(string[] SQL, string[] parameterName, object[] image, string Connection)
        {
            WebService.Url = getUrl();
            //return WebService.UpdateParameterArray(SQL, image, parameterName, Connection);
            return "";
        }
        public bool UpdateD(string SQL, string Parameter, byte[] bin, string Connection)
        {
            WebService.Url = getUrl();
            return WebService.UpdateDATA(SQL, Parameter, bin, Connection);
        }
        public bool UpdateData(string SQL, string Connection)
        {
            //WebService.Url = getUrl();
            //return WebService.UpdateData(SQL, Connection);
            return DirectConnect.Execute(SQL, Connection);
        }
        public DataSet Retreive(string SQL, string Connection)
        {
            return DirectConnect.Retreive(SQL, Connection);

            //        WebService.Url = getUrl();
            //        return WebService.SelectData(SQL, Connection);

        }
        public DataSet SelectData(string SQL, string Connection)
        {
            return DirectConnect.Retreive(SQL, Connection);
            //        WebService.Url = getUrl();
            //        return WebService.SelectData(SQL, Connection);

        }
        public bool InsertData(string SQL, string Connection)
        {
            WebService.Url = getUrl();
            return WebService.InsertData(SQL, Connection);
        }
        public string ReadXML(string Connection, string UserName, string Password)
        {
            WebService.Url = getUrl();
            //return WebService.ReadXML(Connection, UserName, Password);
            return "";
        }
        public bool Execute(string SQL, string Connection)
        {
            return DirectConnect.Execute(SQL, Connection);

            //        WebService.Url = getUrl();
            //        return WebService.UpdateData(SQL, Connection);
        }
        public bool Execute(string SQL, string Connection, out string ErrorMsg)
        {
            ErrorMsg = "";
            WebService.Url = getUrl();
            if (WebService.UpdateData(SQL, Connection)) return true;
            else
            {
                ErrorMsg = WebService.ErrorLog();
                return false;
            }
        }
        //public string SendMail(string From, string To, string Title, string Detail)
        //{
        //    MailService.Url = MailServicegetUrl();
        //    return MailService.Sendmail(From, To, Title, Detail);
        //}

        public string getUrl()
        {
            //return "http://jigsaweng.no-ip.org/Mservice/service.asmx";
            //return "http://192.168.1.254/Mservice/service.asmx";
            return "http://booking.jigsawenglish.com/Mservice/service.asmx";
            //return "http://nextwaver.poweredbyclear.com/Mservice_jigsaw/Service.asmx";
            //return "http://localhost/MService/Service.asmx";
        }
        public string MailServicegetUrl()
        {
            //return "http://122.155.190.7/MailService/Service.asmx";
            return "http://booking.jigsawenglish.com/MailService/Service.asmx";
        }
    }
}
